package cn.iocoder.yudao.module.fengdong.smartelderly.dal.mysql.useroldman;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.fengdong.smartelderly.dal.dataobject.useroldman.UserOldmanDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.fengdong.smartelderly.controller.admin.useroldman.vo.*;

/**
 * 用户关联老人 Mapper
 *
 * @author 沣东养老院管理员
 */
@Mapper
public interface UserOldmanMapper extends BaseMapperX<UserOldmanDO> {

    default PageResult<UserOldmanDO> selectPage(UserOldmanPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserOldmanDO>()
                .likeIfPresent(UserOldmanDO::getName, reqVO.getName())
                .eqIfPresent(UserOldmanDO::getMark, reqVO.getMark())
                .eqIfPresent(UserOldmanDO::getIdentityCard, reqVO.getIdentityCard())
                .betweenIfPresent(UserOldmanDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UserOldmanDO::getId));
    }

    default List<UserOldmanDO> selectList(UserOldmanExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<UserOldmanDO>()
                .likeIfPresent(UserOldmanDO::getName, reqVO.getName())
                .eqIfPresent(UserOldmanDO::getMark, reqVO.getMark())
                .eqIfPresent(UserOldmanDO::getIdentityCard, reqVO.getIdentityCard())
                .betweenIfPresent(UserOldmanDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UserOldmanDO::getId));
    }

    default Long selectCountByIdentityCard(String identityCard){
        return selectCount(new LambdaQueryWrapperX<UserOldmanDO>()
                .eqIfPresent(UserOldmanDO::getIdentityCard, identityCard)
                .orderByDesc(UserOldmanDO::getId));
    }
}
